package dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate;

import vo.ChapterVO;

import mybatis.service.FactoryService;

public class Chapter_dao {

	
	public List<ChapterVO> getChapterList(){
		return FactoryService.getFactory().openSession().selectList("chapterAll");
	}
	public ChapterVO[] getChapterPaging(Map<String,String> map){
		List<ChapterVO> list =FactoryService.getFactory().openSession().selectList("chapterPaging",map);
		ChapterVO[] volist = new ChapterVO[list.size()];
		list.toArray(volist);
		return volist;
	}
	public int getChapterCount(){
		return FactoryService.getFactory().openSession().selectOne("chapterCount");
	}
	public ChapterVO chpaterNewest(){
		return FactoryService.getFactory().openSession().selectOne("chpaterNewest");
		
	}
	public List<ChapterVO> getFromChapterList(int chapter){
		return FactoryService.getFactory().openSession().selectList("fromChapterList",chapter);
	}
	public int addChapter(ChapterVO vo){
		SqlSession ss = FactoryService.getFactory().openSession();
		int result = ss.insert("addChapter",vo);
		System.out.println("result : "+result);
		if(result == 1){
		//	ss.commit();
		}
		return result;
	}
}
